/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.cid.jsfproducts.modelbeans;

import edu.chl.cid.jsfproducts.Product;
import edu.chl.cid.jsfproducts.Product;
import java.util.ArrayList;
import java.util.Arrays;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Mikey
 */
@ManagedBean
@SessionScoped
public class ShoppingCartModelBean {

    private ArrayList<Product> products;
    
    public ArrayList<Product> getProducts() {
        return products;
    }

    public void addProduct(Product product) {
        products.add(product);
    }
    
    public void removeProduct(Product p){
        products.remove(p);
    }
    
    public void removeProducts(Product p) {            
        products.removeAll(Arrays.asList(new Product[]{p}));
    }
    
    public int getNumberOfProducts() {
        return products.size();
    }
    
    /** Creates a new instance of ShoppingCartModelBean */
    public ShoppingCartModelBean() {
        products = new ArrayList<Product>();
    }
}
